//
//  DiscoverSearchViewController.m
//  TryShopping
//
//  Created by Mr.Lee on 2018/5/16.
//  Copyright © 2018年 RuiBen. All rights reserved.
//

#import "DiscoverSearchViewController.h"
#import "HouseholdDetailViewController.h"
#import "LoginViewController.h"
#import "AttributeView.h"
#import "UIView+Extnesion.h"
#import "UIViewExt.h"
#import "UIButton+WebCache.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "HouseholdListCell.h"
#import "DiscoverListModel.h"
#import "TSFooterRefresh.h"          
#import "TSHeaderRefresh.h"
@interface DiscoverSearchViewController ()<UITextFieldDelegate, AttributeViewDelegate, UITableViewDelegate, UITableViewDataSource>
{
    UITextField *searchTextField;
    UIView *myToolBar;
    NSArray *dsData;
    NSArray *jtData;
    NSString *keyword;
    NSMutableArray*modelArray;
    int pageNumber;
    NSString *pageSize;
    NSString *result;
    NSString*TotalCount;
    UITableView *table;
    UIView*noDataView;
    UIButton *userStatusBtn;
}
@property (nonatomic, weak) UIScrollView *scrollView;
@property (nonatomic ,weak) AttributeView *attributeViewDS;
@property (nonatomic ,weak) AttributeView *attributeViewJT;
@end

@implementation DiscoverSearchViewController

- (void)BackAction:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    pageSize = @"20";
    self.view.backgroundColor =[UIColor whiteColor];
    modelArray = [NSMutableArray array];
    [self setUpTopView];
    [self setUpData];
}
- (void)setUpData{
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    NSMutableArray *dataArr = [def objectForKey:@"recentArr"];
    
    NSMutableArray *listAry = [[NSMutableArray alloc]init];
    for (NSString *str in dataArr) {
        if (![listAry containsObject:str]) {
            [listAry addObject:str];
        }
    }
    if (listAry.count > 10) {
        dsData = [listAry subarrayWithRange:NSMakeRange(0, 10)];
    } else{
        dsData = listAry;
    }
    [self createSubViews];
    [self requestGetHotTags];
}

- (void)setUpTopView{
    UIView *topViewP = [[UIView alloc] init];
    topViewP.frame = CGRectMake(0, 0, ScreenWidth, StatusBarAndNavigationBarHeight);
    topViewP.backgroundColor = lanse;
    [self.view addSubview:topViewP];
    
    UIView *topView = [[UIView alloc] init];
    topView.frame = CGRectMake(0, StatusBarHeight, ScreenWidth, 44);
    topView.backgroundColor = lanse;
    [topViewP addSubview:topView];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    UIImage *tinted = [backImage rt_tintedImageWithColor:[UIColor whiteColor]];
    
    UIButton* backButton= [[UIButton alloc] init];
    backButton.frame = CGRectMake(0, 0, 58, 44);
    [backButton setImage:tinted forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    [topView addSubview:backButton];
    
    UIView *topLineView = [[UIView alloc] init];
    topLineView.frame = CGRectMake(0, topView.height-0.5, ScreenWidth, 1);
    topLineView.backgroundColor = [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0];
    [topView addSubview:topLineView];
    
    myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
    myToolBar.backgroundColor=jianpancolor;
    UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
    [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [tubtnDone addTarget:self action:@selector(OnTapDone1) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:tubtnDone];
    UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
    [btnDone111 setTitle:@"搜索" forState:UIControlStateNormal];
    [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
    btnDone111 .titleLabel .font=[UIFont systemFontOfSize:keyboardFot];
    [btnDone111 addTarget:self action:@selector(OnTapDone1) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:btnDone111];
    myToolBar.alpha=alp;
    UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
    [dabtn addTarget:self action:@selector(OnTapDone1) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:dabtn];
    
    UIView *sousuoView=[[UIView alloc]initWithFrame:CGRectMake(backButton.right-5, (topView.height- 65/2)*0.5, ScreenWidth- backButton.width-15+5, 65/2)];
    sousuoView.backgroundColor= [UIColor colorWithRed:82/255.0 green:180/255.0 blue:236/255.0 alpha:0.36];
    sousuoView.layer.cornerRadius = 15.0;
    sousuoView.layer.masksToBounds = YES;
    [topView addSubview:sousuoView];
    
    UIImage* fangdajing = [UIImage imageNamed:@"sousuo"];
    UIImage *fangdajingNew = [fangdajing rt_tintedImageWithColor:[UIColor colorWithHexString:@"92cff3"]];
    UIButton *screenBtnIM = [[UIButton alloc] initWithFrame:CGRectMake(10, 4, 50/2, 50/2)];
    [screenBtnIM setImage:fangdajingNew forState:UIControlStateNormal];
    [sousuoView addSubview:screenBtnIM];
    
    searchTextField = [[UITextField alloc] initWithFrame:CGRectMake(screenBtnIM.right+5, 1, sousuoView.width-screenBtnIM.right -10,65/2)];
    [searchTextField setBorderStyle:UITextBorderStyleNone]; //外框类型
    searchTextField.placeholder = @"搜索关键字"; //默认显示的字
    searchTextField.font = [UIFont systemFontOfSize:14.0];
    [searchTextField setValue:[UIColor colorWithHexString:@"92cff3"] forKeyPath:@"_placeholderLabel.textColor"];
    searchTextField.tag=22;
    searchTextField.returnKeyType = UIReturnKeySearch;
    searchTextField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
    searchTextField.delegate = self;
    searchTextField.tintColor = [UIColor colorWithHexString:@"92cff3"];//光标颜色;
    searchTextField.textColor = [UIColor whiteColor];   // 输入文字颜色
    searchTextField.inputAccessoryView = myToolBar;
    [searchTextField addTarget:self action:@selector(inputFiled:) forControlEvents:UIControlEventEditingChanged];
    [sousuoView addSubview:searchTextField];
}
- (void)requestGetHotTags{
    NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
    NSString* tokenId = [user1 objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:tokenId forKey:@"tokenId"];
    [params setValue:@"Household" forKey:@"tagsType"];

    [MBProgressHUD showIndeterminateHudSub:@"加载中，请稍候。。。" delay:20 view:self.view];
    [HttpRequest requestData:@"/Discover/getHotTags" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        NSLog(@"dataDict == %@", severDataDict.dataDict);
        if (isSuccess) {
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [MBProgressHUD hideProgressHUDInternal:self.view];
                
                NSMutableArray *listArr = [[NSMutableArray alloc] init];
                listArr = [severDataDict.dataDict objectForKey:@"datas"];
        
                NSMutableArray *nameArr = [NSMutableArray array];
                
                for (NSMutableDictionary *dict in listArr) {
                    [nameArr addObject:[dict objectForKey:@"tagName"]];
                }
                jtData = nameArr;
                [self createSubViews];
                
            }else{
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [MBProgressHUD showTextHudSub:requestResultStr view:self.view];
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    LoginViewController*detailViewController = [[LoginViewController alloc] init];
                    [self.navigationController pushViewController:detailViewController animated:YES];
                }
            }
            
        } else {
            [MBProgressHUD hideProgressHUDInternal:self.view];
            [MBProgressHUD showTextHudSub:severDataDict.resultStr view:self.view];
        }
    }];
}

- (void)createSubViews{
    [self.scrollView removeFromSuperview];
    // 创建最底层的scrollview
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, StatusBarAndNavigationBarHeight, ScreenWidth, ScreenHeight-StatusBarAndNavigationBarHeight)];
    self.scrollView = scrollView;
    scrollView.backgroundColor = [UIColor colorWithRed:92/255.0 green:192/255.0 blue:83/255.0 alpha:1.0];
    scrollView.backgroundColor =[UIColor whiteColor];
    scrollView.bounces = YES;
    //    scrollView.showsVerticalScrollIndicator = YES;
    scrollView.alwaysBounceVertical = YES;
    // 创建最近搜索视图
    AttributeView *attributeViewDS = [AttributeView attributeViewWithTitle:@"最近搜索" titleFont:[UIFont boldSystemFontOfSize:13.0] andTitleImageNamed:@"zuijin" andDetailTitle:@"消除" attributeTexts:dsData viewWidth:ScreenWidth];
    attributeViewDS.Attribute_delegate = self;
    self.attributeViewDS = attributeViewDS;
    
    UIView *lineView = [[UIView alloc] init];
    lineView.frame = CGRectMake(10, attributeViewDS.height-0.5, ScreenWidth-20, 0.5);
    lineView.backgroundColor = [UIColor colorWithHexString:@"e4e4e4"];
    [attributeViewDS addSubview:lineView];
    
    jtData = @[@"123"];
    // 创建热门搜索视图
    AttributeView *attributeViewJT = [AttributeView attributeViewWithTitle:@"热门搜索" titleFont:[UIFont boldSystemFontOfSize:13.0] andTitleImageNamed:@"remen" andDetailTitle:@" " attributeTexts:jtData viewWidth:ScreenWidth];
    attributeViewJT.Attribute_delegate = self;
    self.attributeViewJT = attributeViewJT;
    
    // 这里不用设置attriButeView的frame, 只需要设置y值就可以了,而且Y值是必须设置的,高度是已经在内部计算好的.可以更改宽度.
    attributeViewDS.y = 0;
    attributeViewJT.y = CGRectGetMaxY(attributeViewDS.frame);
    
    // 添加到scrollview上
    [scrollView addSubview:attributeViewDS];
    [scrollView addSubview:attributeViewJT];
    scrollView.contentSize = (CGSize){0, CGRectGetMaxY(attributeViewJT.frame)};
    [self.view addSubview:scrollView];

}

- (void)rightBtnClick:(UIButton *)sender{
    if ([sender.titleLabel.text isEqualToString:@"消除"]) {
        dsData = nil;
        [self createSubViews];
        NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
        NSMutableArray *tempArr = [NSMutableArray arrayWithArray:[def objectForKey:@"recentArr"]];
        [tempArr removeAllObjects];
        [def setObject:tempArr forKey:@"recentArr"];
        [def synchronize];
    }
}

#pragma mark - AttributeViewDelegate
- (void)Attribute_View:(AttributeView *)view didClickBtn:(UIButton *)btn{
    NSString *title = btn.titleLabel.text;
    NSLog(@"%@", title);
    keyword = title;
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    NSMutableArray *tempArr = [NSMutableArray arrayWithArray:[def objectForKey:@"recentArr"]];
    if (tempArr== nil) {
        tempArr = [NSMutableArray array];
    }
    [tempArr insertObject:title atIndex:0];
    [def setObject:tempArr forKey:@"recentArr"];
    [def synchronize];
    [self setUpTabelList];
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    [searchTextField resignFirstResponder];
}

- (BOOL)textFieldShouldClear:(UITextField *)textField{
    [searchTextField resignFirstResponder];
    [table removeFromSuperview];
    [self setUpData];
    return YES;
}
- (void)inputFiled:(UITextField *)tf{
    
    NSLog(@"+++");
    if (tf.text.length == 0) {
        NSLog(@"---");
        [searchTextField resignFirstResponder];
        [table removeFromSuperview];
        [self setUpData];
    }
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [searchTextField resignFirstResponder];
    if (textField.text.length >0) {
        NSString *serchWord = textField.text;
        keyword = serchWord;
        NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
        NSMutableArray *tempArr = [NSMutableArray arrayWithArray:[def objectForKey:@"recentArr"]];
        if (tempArr== nil) {
            tempArr = [NSMutableArray array];
        }
        [tempArr insertObject:serchWord atIndex:0];
        
        [def setObject:tempArr forKey:@"recentArr"];
        [def synchronize];
    }
    [self setUpTabelList];
    return YES;
    
}

-(void)OnTapDone1{
    [searchTextField resignFirstResponder];
    if (searchTextField.text.length >0) {
        NSString *serchWord = searchTextField.text;
        keyword = serchWord;
        NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
        NSMutableArray *tempArr = [NSMutableArray arrayWithArray:[def objectForKey:@"recentArr"]];
        if (tempArr== nil) {
            tempArr = [NSMutableArray array];
        }
        [tempArr insertObject:serchWord atIndex:0];
        
        [def setObject:tempArr forKey:@"recentArr"];
        [def synchronize];
    }
    
    [self setUpTabelList];
}

- (void)setUpTabelList {
    [self.scrollView removeFromSuperview];
    [table removeFromSuperview];
    table = [[UITableView alloc]initWithFrame:CGRectMake(0, StatusBarAndNavigationBarHeight, ScreenWidth, ScreenHeight- StatusBarAndNavigationBarHeight) style:UITableViewStylePlain];
    table.delegate = self;
    table.dataSource = self;
    table.separatorStyle=UITableViewCellSeparatorStyleNone;
    [self.view addSubview:table];
    
    UIView*foot=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, StatusBarAndNavigationBarHeight)];
    foot.backgroundColor=[UIColor whiteColor];
    table.tableFooterView=foot;
    
    // 集成刷新控件
    [self setUpRefresh];
    
    // 数据请求
    [self requestData];
    
}

// 刷新
- (void)setUpRefresh {
    table.mj_header = [TSHeaderRefresh headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
    table.mj_footer = [TSFooterRefresh footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreProductList)];
    
}
// 下拉刷新
- (void)headerRefresh {
    [self requestData];
}
-(void)requestData{
    pageNumber=1;
    [noDataView removeFromSuperview];
    [modelArray removeAllObjects];
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:@"1" forKey:@"pageIndex"];
    [param setValue:pageSize forKey:@"pageSize"];
    [param setValue:keyword forKey:@"keyword"];
    NSLog(@"%@", param);
    [MBProgressHUD showIndeterminateHudSub:@"加载中，请稍候。。。" delay:30 view:self.view];
    [HttpRequest requestData:@"/Discover/Household/List" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            [modelArray removeAllObjects];
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [MBProgressHUD hideProgressHUDInternal:self.view];
                NSMutableArray* arrr=[[NSMutableArray alloc]init];
                TotalCount=[severDataDict.dataDict objectForKey:@"TotalCount"];
                arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                for (NSDictionary* dicc in arrr ) {
                    
                    DiscoverListModel *model =[DiscoverListModel  mj_objectWithKeyValues:dicc];
                    [modelArray addObject:model];
                }
                
                if (arrr.count == 0) {
                    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
                    if ([[user objectForKey:@"userStatus"] isEqualToString:@"W"]) {
                        
                    }else{
                        
                        noDataView=[[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight/2-50, ScreenWidth, 80)];
                        [self.view addSubview:noDataView];
                        UIImageView*noImage=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/2-47, 0, 94, 51)];
                        noImage.image=[UIImage imageNamed:@"meiyoushuju"];
                        [noDataView addSubview:noImage];
                        UILabel*noLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,65, ScreenWidth, 14)];
                        noLabel.text=@"没有列表数据，赶紧去添加！";
                        noLabel.textColor=zhonghuiColor; noLabel.font=[UIFont systemFontOfSize:14];
                        noLabel.textAlignment=NSTextAlignmentCenter;
                        [noDataView addSubview:noLabel];
                        
                    }
                }
                TotalCount=[severDataDict.dataDict objectForKey:@"TotalCount"];
                if (TotalCount.intValue < pageSize.intValue) {
                    [table.mj_footer endRefreshingWithNoMoreData];
                } else if(TotalCount.intValue >pageSize.intValue){
                    [table.mj_footer resetNoMoreData];
                }
                [table reloadData];
                
            }else{
                [MBProgressHUD hideProgressHUDInternal:self.view];
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    LoginViewController *loginVC=[[LoginViewController alloc] init];//2.0{9个参数 少2个}
                    [self.navigationController pushViewController:loginVC animated:YES];
                }
            }
            
        } else {
            [MBProgressHUD hideProgressHUDInternal:self.view];
        }
        
    }];
    
}

// 上拉刷新
- (void)loadMoreProductList{
    
    if (TotalCount.floatValue/pageSize.floatValue > pageNumber) {
        pageNumber++;
        NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
        NSString* tokenId = [user1 objectForKey:@"tokenId"];
        NSMutableDictionary *params = [NSMutableDictionary new];
        [params setValue:tokenId forKey:@"tokenId"];
        [params setValue:[NSString stringWithFormat:@"%d" ,pageNumber] forKey:@"pageIndex"];
        [params setValue:pageSize forKey:@"pageSize"];
        //            [params setValue:self.dhTypeCode forKey:@"dhTypeCode"];
        [params setValue:keyword forKey:@"keyword"];
        [MBProgressHUD showIndeterminateHudSub:@"加载中，请稍候。。。" delay:30 view:self.view];
        [HttpRequest requestData:@"/Discover/Household/List" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [MBProgressHUD hideProgressHUDInternal:self.view];
                    NSMutableArray* arrr=[[NSMutableArray alloc]init];
                    arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                    for (NSDictionary* dicc in arrr ) {
                        DiscoverListModel *model =[DiscoverListModel  mj_objectWithKeyValues:dicc];
                        [modelArray addObject:model];
                    }
                    [table reloadData];
                    
                    TotalCount=[severDataDict.dataDict objectForKey:@"TotalCount"];
                    if (TotalCount.intValue < pageSize.intValue) {
                        [table.mj_footer endRefreshingWithNoMoreData];
                    } else if(TotalCount.intValue >pageSize.intValue){
                        [table.mj_footer resetNoMoreData];
                    }
                }else {
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [MBProgressHUD showTextHudSub:requestResultStr view:self.view];
                }
                
            } else {
                [MBProgressHUD hideProgressHUDInternal:self.view];
                [MBProgressHUD showTextHudSub:severDataDict.resultStr view:self.view];
            }
        }];
    }else{
        NSString *requestResultStr=@"没有更多数据了！";
        [MBProgressHUD showTextHudSub:requestResultStr view:self.view];
        [table.mj_footer endRefreshingWithNoMoreData];
        
    }
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return modelArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    HouseholdListCell* cell = (HouseholdListCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"HouseholdListCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    DiscoverListModel *model = modelArray[indexPath.row];
    [cell.imageUrl.layer setCornerRadius:4.0];
    [cell.imageUrl.layer setBorderWidth:0.3];
    [cell.imageUrl.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0.93, 0.93, 0.93, 0.93 });
    [cell.imageUrl.layer setBorderColor:colorref2];//边框颜色
    
    [cell.imageUrl setImageWithURL:[NSURL URLWithString:model.imageUrlFull] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
    
    cell.title.text =[NSString stringWithFormat:@"%@",  model.title];
    
    
    NSString* string =  model.pubTime;
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
    NSDate *destDate= [dateFormatter dateFromString:string];
    
    NSString *result1= nil;
    NSTimeInterval  timeInterval = [destDate timeIntervalSinceNow];
    timeInterval = -timeInterval;
    long temp = 0;
    if (timeInterval < 60) {
        result1 = [NSString stringWithFormat:@"刚刚"];
    }else if((temp = timeInterval/60) <60){
        result1 = [NSString stringWithFormat:@"%ld分前",temp];
    }else if((temp = temp/60) <24){
        result1 = [NSString stringWithFormat:@"%ld小时前",temp];
    }else if((temp = temp/24) <30){
        result1 = [NSString stringWithFormat:@"%ld天前",temp];
    }else if((temp = temp/30) <12){
        result1 = [NSString stringWithFormat:@"%ld月前",temp];
    }else{
        temp = temp/12;
        result1 = [NSString stringWithFormat:@"%ld年前",temp];
    }
    cell.time.text =[NSString stringWithFormat:@"%@",  result1];
    cell.author.text =[NSString stringWithFormat:@"%@",  model.author];
    
    UIView *lineLabel1=[[UIView alloc] initWithFrame:CGRectMake(10, 100-0.50, ScreenWidth-20, 0.50)];
    lineLabel1.backgroundColor=qianhuiColor;
    [cell.contentView addSubview:lineLabel1];
    
    return cell;
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return  100;
}

#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    DiscoverListModel *model = modelArray[indexPath.row];
    HouseholdDetailViewController *detailViewController = [[HouseholdDetailViewController alloc] init];
    //    detailViewController.ImageUrl = model.imageUrlFull;
    detailViewController.fid = model.fid;
    //    detailViewController.titleStr = model.title;
    //    detailViewController.content = model.content;
    [self.navigationController pushViewController:detailViewController animated:YES];
}

@end
